<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:SimpleFMMatrix">

    <Style TargetType="{x:Type local:EnvelopePhaseCurve}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:EnvelopePhaseCurve}">
                    <Canvas>
                        <Path x:Name="seenStroke" IsHitTestVisible="False" Stroke="#C0000000" StrokeThickness="0.7" Data="{TemplateBinding Curve}" />
                        <Path x:Name="hitStroke" IsHitTestVisible="True" Stroke="Transparent" StrokeThickness="25" Data="{TemplateBinding Curve}" />
                        <Path x:Name="filledStroke" IsHitTestVisible="False" Fill="#10000000" Data="{TemplateBinding ClosedCurve}" />
                    </Canvas>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="seenStroke" Property="StrokeThickness" Value="1.5" />
                            <Trigger.EnterActions>
                                <StopStoryboard BeginStoryboardName="mouseleave" />
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard x:Name="mouseleave">
                                    <Storyboard DecelerationRatio="1" FillBehavior="Stop">
                                        <DoubleAnimation From="1.5" To="0.7" Duration="0:0:0.3" 
                                                         Storyboard.TargetName="seenStroke"
                                                         Storyboard.TargetProperty="StrokeThickness" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsDragging" Value="True">
                            <Setter TargetName="seenStroke" Property="Stroke" Value="#80000000" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:EnvelopePhaseDuration}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:EnvelopePhaseDuration}">
                    <local:ZeroWidthPanel>
                        <Rectangle x:Name="seen" IsHitTestVisible="False" Fill="#C0000000" Width="0.7" />
                        <Rectangle x:Name="hit" IsHitTestVisible="True" Fill="Transparent" Width="10" />
                    </local:ZeroWidthPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="seen" Property="Width" Value="1.5" />
                            <Trigger.EnterActions>
                                <StopStoryboard BeginStoryboardName="mouseleave" />
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard x:Name="mouseleave">
                                    <Storyboard DecelerationRatio="1" FillBehavior="Stop">
                                        <DoubleAnimation From="1.5" To="0.7" Duration="0:0:0.3" 
                                                         Storyboard.TargetName="seen"
                                                         Storyboard.TargetProperty="Width" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsDragging" Value="True">
                            <Setter TargetName="seen" Property="Fill" Value="#80000000" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:EnvelopePointLevel}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:EnvelopePointLevel}">
                    <local:ZeroWidthPanel>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="{Binding Path=UpperLength, RelativeSource={RelativeSource TemplatedParent}}" />
                                <RowDefinition Height="0" />
                                <RowDefinition Height="{Binding Path=LowerLength, RelativeSource={RelativeSource TemplatedParent}}" />
                            </Grid.RowDefinitions>
                            <local:ZeroHeightPanel Grid.Row="1" Width="20">
                                <Rectangle x:Name="seen" IsHitTestVisible="False" Fill="#C0000000" Height="0.7" />
                                <Rectangle x:Name="hit" IsHitTestVisible="True" Fill="Transparent" Height="10" />
                            </local:ZeroHeightPanel>
                        </Grid>
                    </local:ZeroWidthPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="seen" Property="Height" Value="1.5" />
                            <Trigger.EnterActions>
                                <StopStoryboard BeginStoryboardName="mouseleave" />
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard x:Name="mouseleave">
                                    <Storyboard DecelerationRatio="1" FillBehavior="Stop">
                                        <DoubleAnimation From="1.5" To="0.7" Duration="0:0:0.3" 
                                                         Storyboard.TargetName="seen"
                                                         Storyboard.TargetProperty="Height" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsDragging" Value="True">
                            <Setter TargetName="seen" Property="Fill" Value="#80000000" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:MatrixEntry}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:MatrixEntry}">
                    <Grid Background="Transparent">
                        <Grid Width="50" Height="42" Margin="3">
                            <Rectangle x:Name="bg" Fill="#10000000" />
                            <Rectangle x:Name="cover" Fill="#20000000" Opacity="0" />
                            <Rectangle>
                                <Rectangle.Fill>
                                    <VisualBrush Stretch="Uniform">
                                        <VisualBrush.Visual>
                                            <TextBlock Text="{TemplateBinding OperatorName}"
                                                       FontWeight="Light" Foreground="#80FFFFFF" />
                                        </VisualBrush.Visual>
                                    </VisualBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <TextBlock x:Name="t" VerticalAlignment="Center" TextAlignment="Center"
                                       FontSize="28" FontWeight="Light"
                                       Text="{Binding Path=Value, RelativeSource={RelativeSource TemplatedParent}}" />
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Value" Value="0">
                            <Setter TargetName="t" Property="Visibility" Value="Hidden" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="cover" Property="Opacity" Value="1" />
                            <Trigger.EnterActions>
                                <StopStoryboard BeginStoryboardName="mouseleave" />
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard x:Name="mouseleave">
                                    <Storyboard DecelerationRatio="1" FillBehavior="Stop">
                                        <DoubleAnimation From="1" To="0" Duration="0:0:0.3" 
                                                         Storyboard.TargetName="cover"
                                                         Storyboard.TargetProperty="Opacity" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsDragging" Value="True">
                            <Setter TargetName="cover" Property="Fill" Value="#10000000" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:FrequencyNumberView}">
        <Setter Property="FontWeight" Value="Light" />
        <Setter Property="FontSize" Value="26" />
        <Setter Property="Padding" Value="3,0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:FrequencyNumberView}">
                    <Grid Background="Transparent" HorizontalAlignment="Center">
                        <Grid VerticalAlignment="Center" Height="{TemplateBinding FontSize}">
                            <Rectangle Height="0.25" Fill="Black" VerticalAlignment="Bottom" Margin="3,-6" />
                        </Grid>
                        <StackPanel Orientation="Horizontal" Margin="{TemplateBinding Padding}">
                            <local:IntValuedThumb x:Name="PART_I1" />
                            <local:IntValuedThumb x:Name="PART_I0" />
                            <TextBlock VerticalAlignment="Center" TextAlignment="Center" Text="." />
                            <local:IntValuedThumb x:Name="PART_F0" />
                            <local:IntValuedThumb x:Name="PART_F1" />
                            <local:IntValuedThumb x:Name="PART_F2" />
                            <local:IntValuedThumb x:Name="PART_F3" />
                        </StackPanel>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:IntValuedThumb}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:IntValuedThumb}">
                    <Grid>
                        <Rectangle x:Name="bg" Fill="#20000000" Opacity="0" />
                        <TextBlock x:Name="t" VerticalAlignment="Center" TextAlignment="Center"
                                   Text="{Binding Path=Value, RelativeSource={RelativeSource TemplatedParent}}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsNumberShown" Value="False">
                            <Setter TargetName="t" Property="Visibility" Value="Hidden" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="bg" Property="Opacity" Value="1" />
                            <Trigger.EnterActions>
                                <StopStoryboard BeginStoryboardName="mouseleave" />
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard x:Name="mouseleave">
                                    <Storyboard DecelerationRatio="1" FillBehavior="Stop">
                                        <DoubleAnimation From="1" To="0" Duration="0:0:0.3" 
                                                         Storyboard.TargetName="bg"
                                                         Storyboard.TargetProperty="Opacity" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsDragging" Value="True">
                            <Setter TargetName="bg" Property="Fill" Value="#10000000" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:EnvelopeZoomThumb}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:EnvelopeZoomThumb}">
                    <Rectangle x:Name="bg" Fill="Transparent" Stroke="Black" StrokeThickness="0.3" Opacity="0" />
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="bg" Property="Opacity" Value="1" />
                            <Trigger.EnterActions>
                                <StopStoryboard BeginStoryboardName="mouseleave" />
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard x:Name="mouseleave">
                                    <Storyboard DecelerationRatio="1" FillBehavior="Stop">
                                        <DoubleAnimation From="1" To="0" Duration="0:0:0.3" 
                                                         Storyboard.TargetName="bg"
                                                         Storyboard.TargetProperty="Opacity" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsDragging" Value="True">
                            <Setter TargetName="bg" Property="Stroke" Value="#80000000" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:PianoKeyControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:PianoKeyControl}">
                    <Grid>
                        <Rectangle x:Name="rect" Fill="White" Stroke="#202020" StrokeThickness="0.5" />
                        <Rectangle x:Name="cover" Fill="#40000000" Visibility="Collapsed" />
                        <Rectangle x:Name="cover2" Stroke="Black" StrokeThickness="1" Visibility="Collapsed" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsBlackKey" Value="True">
                            <Setter Property="Panel.ZIndex" Value="1" />
                            <Setter TargetName="rect" Property="Fill" Value="#404040" />
                            <Setter TargetName="cover" Property="Fill" Value="Black" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="cover2" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="cover" Property="Visibility" Value="Visible" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
